package com.wxy.config;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author 47868
 */
@Configuration
public class ElasticSearchConfig {
    private final ElasticsearchClient client;
    @Autowired
    public ElasticSearchConfig(ElasticsearchClient client) {
        this.client = client;
    }
    @PreDestroy
    public void destroy() throws IOException {
        if(null != client) {
            client._transport().close();
        }
    }
}
